package com.thinkcube.edutainment.fragment;

import android.app.Dialog;
import android.app.DialogFragment;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.thinkcube.edutainment.R;

public class NoticeDialogFragment extends DialogFragment implements OnClickListener {
	
	Button ok;
	Button cancel;
	TextView msg;
	public onSubmitListener mListener;
	public String msgtext;
	
	public interface onSubmitListener {  
		  void onDialogOkClick(String s);
		  void onDialogCancelClick(String a );
		 }  
	
	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState) {
		final Dialog dialog = new Dialog(getActivity());  
		  dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
		  dialog.setContentView(R.layout.dialog); 
		  dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.BLACK));  
		  dialog.show();  
		  ok = (Button) dialog.findViewById(R.id.ok); 
		  cancel=(Button) dialog.findViewById(R.id.cancel);
		  msg = (TextView) dialog.findViewById(R.id.dialog_text);  
		  msg.setText(msgtext);  
		  ok.setOnClickListener(this);
		  cancel.setOnClickListener(this);
		  return dialog;  
		
	}

	@Override
	public void onClick(View v) {
		if(v.getId()==R.id.ok)
		{
			 mListener.onDialogOkClick(msg.getText().toString());  
			 dismiss(); 
		}
		else if(v.getId()==R.id.cancel)
		{
			mListener.onDialogCancelClick(msg.getText().toString()); 
		}
		
	}

}
